﻿using UnityEngine;
using System.Collections;

public class Spawner:MonoBehaviour {



    public float spawnTime = 5f;
    public float spawnDelay = 3f;
    public GameObject[] enemies;

    // Use this for initialization
    void Start() {

        //可反复调用衍生函数。
        InvokeRepeating("Spawn",spawnDelay,spawnTime);
    }


    void Spawn() {

        // 随机获取一个敌人数组下标 
        int enemyIndex = Random.Range(0,enemies.Length);

        Instantiate(enemies[enemyIndex],transform.position,transform.rotation);



    }


}
